#ifndef __USART_H
#define __USART_H

#include "sys.h"

#define BAUD_RATE_2400                  2400
#define BAUD_RATE_4800                  4800
#define BAUD_RATE_9600                  9600
#define BAUD_RATE_19200                 19200
#define BAUD_RATE_38400                 38400
#define BAUD_RATE_57600                 57600
#define BAUD_RATE_115200                115200
#define BAUD_RATE_230400                230400
#define BAUD_RATE_460800                460800
#define BAUD_RATE_921600                921600
#define BAUD_RATE_2000000               2000000
#define BAUD_RATE_3000000               3000000

#define DATA_BITS_5                     5
#define DATA_BITS_6                     6
#define DATA_BITS_7                     7
#define DATA_BITS_8                     8
#define DATA_BITS_9                     9

#define STOP_BITS_1                     0
#define STOP_BITS_2                     1
#define STOP_BITS_3                     2
#define STOP_BITS_4                     3

#define PARITY_NONE                     0
#define PARITY_ODD                      1
#define PARITY_EVEN                     2


extern uint8_t uart_init(uint8_t u, uint32_t baudrate, uint8_t databit, uint8_t stopbit, uint8_t parity);
extern void uart_send(uint8_t u, uint8_t *data, uint16_t len);
extern void uart_send_dma(uint8_t u, uint8_t *data, uint16_t len);
extern void uart_rev_init(uint8_t u);
extern uint16_t uart_rev_length(uint8_t u);
extern int uart_get_byte(uint8_t u);
extern void uart_set_ringbuf(uint8_t u, void * buffer, uint16_t size);
extern int uart_write_ready(uint8_t u);


#endif
